home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / os2 / sysb091a.zip / sysbench / src / pmb_main.c < prev    next >
Text File  |  1996-06-08  |  39KB  |  1,229 lines

  1. // Sysbench main file
  2. //#define INCL_NOCOMMON
  3. #define INCL_DOSMISC
  4. #define INCL_DOSDEVICES
  5. #define INCL_DOSPROCESS
  6. #define INCL_DOSDEVIOCTL
  7. //#define INCL_DOSSEMAPHORES
  8. #define INCL_DOSERRORS
  9. #define INCL_WINWINDOWMGR
  10. #define INCL_WINMESSAGEMGR
  11. #define INCL_WINFRAMEMGR
  12. #define INCL_WINDIALOGS
  13. #define INCL_WININPUT
  14. #define INCL_WINSWITCHLIST
  15. #define INCL_WINPROGRAMLIST
  16. #define INCL_WINERRORS          /* Window Error Functions       */
  17. #define INCL_WINDESKTOP
  18. #define INCL_WINSTDFILE
  19. #define INCL_GPICONTROL
  20. #define INCL_GPIPRIMITIVES
  21.  
  22. #define INCL_WIN
  23. #define INCL_PM
  24. #define IDM_RESOURCE 1
  25. #define INCL_GPI
  26. #define INCL_GPILCIDS
  27. #define INCL_GPIPRIMITIVES
  28.  
  29. #include <os2.h>
  30. #include <time.h>
  31. #include <stdio.h>
  32. #include <stdlib.h>
  33. #include <string.h>
  34. #include "types.h"
  35. #include "pmb.h"
  36. #include "pmb_bench.h"
  37. #include "pmb_datatype.h"
  38.  
  39. #define CLS_CLIENT   "SysBenchWindowClass"
  40. #define SYSB_VER     "0.9.1"
  41. #define THR_DONE     (WM_USER + 1)
  42. #define THR_UPDATE   (WM_USER + 2)
  43. #define START_STACKSIZE 65536
  44. #define DISP_LINES (75)
  45. #define MB           (1048576)
  46. #define KB            1024
  47. #define MN            1000000
  48.  
  49. // ********** IMPORTED FUNCTIONS
  50. extern int pmb_diskio_disksize(int nr);
  51. extern int pmb_diskio_nrdisks(void);
  52. extern void log(char* s);
  53.  
  54. // ********** EXPORTED FUNCTIONS
  55. void err(char* s);
  56. void InfoBox(char* s);
  57. void WarnBox(char* s);
  58. void ErrorBox(char* s);
  59.  
  60. // ********** LOCAL FUNCTIONS
  61. static void SetTitle(char* s);
  62. static void UpdateWindow(HPS hpsPaint, PRECTL pRect, s32 scrollValue);
  63. static void Print(s32 row, s32 col, char* string, PRECTL pRect,
  64.                   s32 scrollValue, HPS hpsPaint, s32 color);
  65. static void SetMenuState(bool active);
  66. static void UpdateAll(void);
  67. static void SaveResults(void);
  68. static void PrintFile(s32 newlines, s32 col, char* string, FILE* fp);
  69.  
  70. MRESULT EXPENTRY ClientWindowProc ( HWND hwndWnd,
  71.    ULONG ulMsg,
  72.    MPARAM mpParm1,
  73.    MPARAM mpParm2 );
  74.  
  75. // ********** EXPORTED DATA
  76. double test_time;
  77. static HWND   hwndClient = NULLHANDLE;
  78. static HWND   hwndVertScroll;
  79. static HWND   hwndMenu;
  80.  
  81. // ********** LOCAL DATA
  82. static bool thread_running;
  83. static s32  fontW;
  84. static s32  fontH;
  85. static HPS  mainHps = NULLHANDLE;
  86. //static HAB  hab = NULLHANDLE;
  87. static s32 scroll = 0;
  88. static s32 oldscroll = 0;
  89. static  HWND        hwndFrame = NULLHANDLE;
  90.  
  91. struct glob_data data = {
  92.   1,
  93.   1,
  94.   { 100, 100, 100, 100, 100, 100, 100, 100, 100, 100 },
  95.   {
  96.     {
  97.       "Graphics",
  98.       8,
  99.       {
  100.         { "BitBlt S->S cpy",  -1.0, MN, "Mpixels/s" },
  101.         { "BitBlt M->S cpy",  -1.0, MN, "Mpixels/s" },
  102.         { "Filled Rectangle", -1.0, MN, "Mpixels/s" },
  103.         { "Pattern Fill",     -1.0, MN, "Mpixels/s" },
  104.         { "Vertical Lines",   -1.0, MN, "Mpixels/s" },
  105.         { "Horizontal Lines", -1.0, MN, "Mpixels/s" },
  106.         { "Diagonal Lines",   -1.0, MN, "Mpixels/s" },
  107.         { "Text Render",      -1.0, MN, "Mpixels/s" }
  108.       },
  109.       -1.0,
  110.       "PM-marks"
  111.     },
  112.     {
  113.       "CPU integer",
  114.       4,
  115.       {
  116.         { "Dhrystone",      -1.0, MN, "VAX 11/780 MIPS" },
  117.         { "Hanoi",          -1.0, 1, "moves/25 usec" },
  118.         { "Heapsort",       -1.0, MN, "MIPS" },
  119.         { "Sieve",          -1.0, MN, "MIPS" }
  120.       },
  121.       -1.0,
  122.       "CPUint-marks"
  123.     },
  124.     {
  125.       "CPU float",
  126.       3,
  127.       {
  128.         { "Linpack",            -1.0, 1000, "MFLOPS" },
  129.         { "Flops",              -1.0, MN, "MFLOPS" },
  130.         { "Fast Fourier Tr.",   -1.0, 1, "VAX FFT's" }
  131.       },
  132.       -1.0,
  133.       "CPUfloat-marks"
  134.     },
  135.     {
  136.       "Direct Interface to video extensions - DIVE",
  137.       3,
  138.       {
  139.         { "Video bus bandw.",    -1.0, MB, "MB/s" },
  140.         { "DIVE fun",            -1.0, 1, "fps at 640x480x256"  },
  141.         { "M->S, DD,   1.00:1",  -1.0, 1, "fps at 640x480x256"  }
  142.       },
  143.       -1.0,
  144.       "DIVE-marks"
  145.     },
  146.     {
  147.       "Disk I/O",
  148.       4,
  149.       {
  150.         { "Avg. data access time",   -1.0, 1.0e-03, "ms" },
  151.         { "Cache/Bus xfer rate  ",   -1.0, MB, "MB/s" },
  152.         { "Average Transfer rate",   -1.0, MB, "MB/s" },
  153.         { "Disk use CPU load    ",   -1.0, 1, "percent" }
  154.       },
  155.       -1.0,
  156.       "DiskIO-marks"
  157.     },
  158.     {
  159.       "Memory",
  160.       27,
  161.       {
  162.         { "5    kB copy", -1.0, MB, "MB/s" },
  163.         { "10   kB copy", -1.0, MB, "MB/s" },
  164.         { "20   kB copy", -1.0, MB, "MB/s" },
  165.         { "40   kB copy", -1.0, MB, "MB/s" },
  166.         { "80   kB copy", -1.0, MB, "MB/s" },
  167.         { "160  kB copy", -1.0, MB, "MB/s" },
  168.         { "320  kB copy", -1.0, MB, "MB/s" },
  169.         { "640  kB copy", -1.0, MB, "MB/s" },
  170.         { "1280 kB copy", -1.0, MB, "MB/s" },
  171.         { "5    kB read", -1.0, MB, "MB/s" },
  172.         { "10   kB read", -1.0, MB, "MB/s" },
  173.         { "20   kB read", -1.0, MB, "MB/s" },
  174.         { "40   kB read", -1.0, MB, "MB/s" },
  175.         { "80   kB read", -1.0, MB, "MB/s" },
  176.         { "160  kB read", -1.0, MB, "MB/s" },
  177.         { "320  kB read", -1.0, MB, "MB/s" },
  178.         { "640  kB read", -1.0, MB, "MB/s" },
  179.         { "1280 kB read", -1.0, MB, "MB/s" },
  180.         { "5    kB write", -1.0, MB, "MB/s" },
  181.         { "10   kB write", -1.0, MB, "MB/s" },
  182.         { "20   kB write", -1.0, MB, "MB/s" },
  183.         { "40   kB write", -1.0, MB, "MB/s" },
  184.         { "80   kB write", -1.0, MB, "MB/s" },
  185.         { "160  kB write", -1.0, MB, "MB/s" },
  186.         { "320  kB write", -1.0, MB, "MB/s" },
  187.         { "640  kB write", -1.0, MB, "MB/s" },
  188.         { "1280 kB write", -1.0, MB, "MB/s" },
  189.       },
  190.       -1.0,
  191.       "Mem-marks"
  192.     }
  193.   }
  194. };
  195.  
  196.  
  197. INT main ( VOID )
  198. {
  199.       FATTRS      fat;
  200.       LONG        match;
  201.       FONTMETRICS fmMetrics ;
  202.   HMQ         hmq = NULLHANDLE;
  203.   HAB         hab = NULLHANDLE;      /* PM anchor block handle         */
  204.   HAB         hab1 = NULLHANDLE;      /* PM anchor block handle         */
  205.   HWND  hwndDeskTop;
  206.   ERRORID     erridErrorCode;/* last error id code                   */
  207.   ULONG       flCreate = 0UL;
  208.   BOOL        bLoop;
  209.   QMSG        qmsg;
  210.   RECTL       rect;
  211.   s32         x,y,w,h, i;
  212.   MENUITEM    mi;
  213.   HWND        hwndPullDown;
  214.   CHAR        tmp[256];
  215.   int         rc = 1;
  216.  
  217.   if ( ( hab = WinInitialize ( 0UL ) ) == NULLHANDLE )
  218.         exit(2);
  219.  
  220.   if ( ( hmq = WinCreateMsgQueue ( hab, 0UL ) ) == NULLHANDLE )
  221.         exit(3);
  222.  
  223.   erridErrorCode = WinGetLastError(hab);
  224.  
  225.   rc = WinRegisterClass ( hab,
  226.                      CLS_CLIENT,
  227.                      ClientWindowProc,
  228.                      CS_SIZEREDRAW,       /*  CS_SYNCPAINT |  */
  229.                      0UL );
  230.  
  231.   erridErrorCode = WinGetLastError(hab);
  232.  
  233.   if ( rc != TRUE )
  234.  
  235.          {
  236.            log("WinRegisterClass failed") ;
  237.            exit(4);
  238.            }
  239.  
  240.  
  241.   flCreate = FCF_TITLEBAR | FCF_SYSMENU | FCF_SIZEBORDER | FCF_MENU |
  242.             FCF_MINMAX | FCF_TASKLIST | FCF_NOBYTEALIGN | FCF_VERTSCROLL;
  243.  
  244.   hwndDeskTop = WinQueryDesktopWindow(hab1,
  245.                                      NULLHANDLE);
  246.  
  247.   hwndFrame = WinCreateStdWindow( hwndDeskTop,
  248.                                    WS_VISIBLE,
  249.                                    &flCreate,
  250.                                    CLS_CLIENT,
  251.                                    SYSB_VER,
  252.                                    CS_SIZEREDRAW,
  253.                                    NULLHANDLE,
  254.                                    WND_MAIN,
  255.                                    &hwndClient );
  256.  
  257.    erridErrorCode = WinGetLastError(hab);
  258.  
  259.   if ( hwndFrame == NULLHANDLE )
  260.       {
  261.          log("hwndFrame is NULLHANDLE");
  262.          exit(6);
  263.       }
  264.  
  265.  
  266.   mainHps = WinGetPS(hwndClient);
  267.  
  268.   fat.usRecordLength = sizeof(FATTRS); /* sets size of structure   */
  269.   fat.fsSelection = 0;         /* uses default selection           */
  270.   fat.lMatch = 0;              /* does not force match             */
  271.   fat.idRegistry = 0;          /* uses default registry            */
  272.   fat.usCodePage = 0;          /* code-page 850                    */
  273.   fat.lMaxBaselineExt = 12L;   /* requested font height is 12 pels */
  274.   fat.lAveCharWidth = 8L;      /* requested font